using System;
using System.Xml.Linq;

namespace UtilsExtensionsAndHelpers.Helpers
{
    public interface ISerializationHelper
    {
        /// <summary>
        /// Get or set the action that provides feedback. 
        /// A message (string) will be passed in.
        /// IE. Log(message), Console.WriteLine(message)
        /// </summary>
        Action<string> FeedbackProvider { get; set; }

        /// <summary>
        /// Serializes an object.
        /// </summary>
        /// <param name="model">The object you want to Serialize</param>
        /// <returns>The serialized xml in the form of a string.</returns>
        String Serialize(Object model);

        /// <summary>
        /// Serialize an object to a file.
        /// </summary>
        /// <param name="model">The object you want to serialize.</param>
        /// <param name="fileName">The name of the file you want to serialize to.</param>
        void SerializeToFile(Object model, string fileName);

        /// <summary>
        /// Deserializes an object.
        /// </summary>
        /// <param name="model">The object you want to Deserialize</param>
        /// <returns>The deserialized object.</returns>
        T Deserialize<T>(String xmlSerializedObject);

        T Deserialize<T>(XElement xmlSerializedObject);

        /// <summary>
        /// Deserializes an object.
        /// </summary>
        /// <param name="model">The object you want to Deserialize</param>
        /// <returns>The deserialized object.</returns>
        T DeserializeFromFile<T>(string fileName);

        /// <summary>
        /// Converts UTF8 Byte Array to a string. This is used in the serialize 
        /// method so I can write to a memory stream instead of a file.
        /// </summary>
        String UTF8ByteArrayToString(Byte[] characters);

        /// <summary>
        /// Converts a string to a UTF8 Byte Array. This is This is used in the 
        /// deserialize method so I can read from a memory stream instead of a file.
        /// </summary>
        Byte[] StringToUTF8ByteArray(String pXmlString);
    }
}